﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ServerMonitoringAssistantWF
{
    public partial class FrmTimeSetting : Form
    {
        public Action<decimal> SetTimeHandler { get; set; }
        public FrmTimeSetting()
        {
            InitializeComponent();
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            if (null == cbb_unit.SelectedItem || null== SetTimeHandler || tb_number.Value<1)
            {
                return;
            }
            int seconds = 1;
            switch (cbb_unit.SelectedItem.ToString())
            {
                case "分钟":
                    seconds = 60;
                    break;
                case "小时":
                    seconds = 3600;
                    break;
                case "星期":
                    seconds = 7*24*3600;
                    break;
                case "月":
                    seconds = 30*24*3600;
                    break;
            }
            SetTimeHandler(seconds * tb_number.Value);
            this.Close();
        }
    }
}
